package JDK8;

import org.junit.Test;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

/*
    Stream流的应用
 */
public class StreamDemo02 {
    @Test
    public void test1(){

    }

    @Test
    public void test2(){
        Map<Integer,String> map=new HashMap<>();
        //将key值转换为Stream流
        Stream<Integer> keyStream=map.keySet().stream();
        //将value转换为Stream流
        Stream<String> valuesStream=map.values().stream();
        //把完整的键值对转换为Stream流
        Stream<Map.Entry<Integer,String>> mapStream=map.entrySet().stream();
    }

    @Test
    public void test3(){
        int arr[]={1,2,3,4};
        Stream<int[]> arrStream= Stream.of(arr);

        String strs[]={"1","2"};
        Stream<String> strsStream=Stream.of(strs);
    }
}
